
from itsdangerous import TimedJSONWebSignatureSerializer as Serializen
from itsdangerous import BadData



def generate_access_token(openid):
    s = Serializen('secret_key', 600)
    data = {'openid': openid}
    token = s.dumps(data)
    return token.decode()



def save_genrate_access_token(token):
    s = Serializen('secret_key', 600)

    try:
        data = s.loads(token)
    except BadData:
        return None
    else:

        return data.get('openid')